import {getGirls} from '../api'

export default {
  state: () => ({
    girls: [],
    size: 10,
    page: 1
  }),
  getters: {},
  mutations: {
    SET_GIRLS (state, data) {
      state.girls = [...state.girls, ...data]
    },
    SET_PAGE (state) {
      state.page += 1
    }
  },
  actions: {
    async getGirlsAction({commit, state}) {
      const res = await getGirls({
        page: state.page,
        size: state.size
      })
      commit('SET_GIRLS', res.data.data)
    },
    async getNextGirlsAction({state, commit, dispatch}) {
      commit('SET_PAGE')
      dispatch('getGirlsAction')
      console.log(state.page)
    }
  },
  namespaced: true,
}

